<template>
  <div class="edit-popup">
    <el-card class="!border-none" shadow="never">
      <el-button v-perms="['customerlist:add/edit']" type="primary" :disabled="disabled">
        <template #icon>
          <icon name="local-icon-qiehuan" />
        </template>
        转移给其他人
      </el-button>
    </el-card>
    <el-card class="mt-2 !border-none" shadow="never">
      <el-form
        ref="formRef"
        :model="formData"
        label-width="200px"
        :rules="formRules"
        :inline="true"
        class="formEdit"
        :disabled="disabled"
      >
        <!-- <el-form
          ref="formRef"
          class="mb-[-16px]"
          :model="queryParams"
          :inline="true"
        > -->
        <el-collapse v-model="activeNames">
          <el-collapse-item title="基本信息" name="1">
            <el-form-item label="客户编号" prop="customerId">
              <el-input v-model="formData.customerId" placeholder="请输入客户编号" />
            </el-form-item>
            <el-form-item label="案件类型" prop="caseType">
              <el-checkbox-group v-model="formData.caseType">
                <el-checkbox
                  label="全选"
                  name="caseType"
                  @change="handleCheckAllChange"
                ></el-checkbox>
                <el-checkbox label="专利" name="caseType"></el-checkbox>
                <el-checkbox label="商标" name="caseType"></el-checkbox>
                <el-checkbox label="版权" name="caseType"></el-checkbox>
                <el-checkbox label="科技服务" name="caseType"></el-checkbox>
                <el-checkbox label="法律案件" name="caseType"></el-checkbox>
                <el-checkbox label="调查案" name="caseType"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="客户代码" prop="customerCode">
              <el-input v-model="formData.customerCode" placeholder="请输入客户代码" />
            </el-form-item>
            <el-form-item label="客户名称(中)" prop="customerNameChinese">
              <el-input
                v-model="formData.customerNameChinese"
                style="width: 330px"
                placeholder="请输入客户名称(中)"
              />
              <el-button type="primary"> 查重 </el-button>
            </el-form-item>
            <el-form-item label="客户名称(英)" prop="customerNameEnglish">
              <el-input v-model="formData.customerNameEnglish" placeholder="请输入客户名称(英)" />
            </el-form-item>
            <el-form-item label="客户网址" prop="customerWebsite">
              <el-input v-model="formData.customerWebsite" placeholder="请输入客户网址" />
            </el-form-item>
            <el-form-item label="公司负责人" prop="companyOfficials">
              <el-input v-model="formData.companyOfficials" placeholder="请输入公司负责人" />
            </el-form-item>
            <!-- <el-form-item label="所属行业编号" prop="industryInvolvedId">
                <el-input
                  v-model="formData.industryInvolvedId"
                  placeholder="请输入所属行业编号"
                />
              </el-form-item> -->
            <el-form-item label="所属行业" prop="industryInvolved">
              <el-select
                v-model="formData.industryInvolved"
                class="flex-1"
                placeholder="请选择所属行业"
              >
                <el-option label="服务页" value="1" />
                <el-option label="制造业" value="2" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="业务合作编号" prop="businessCooperationId">
                <el-input
                  v-model="formData.businessCooperationId"
                  placeholder="请输入业务合作编号"
                />
              </el-form-item> -->
            <el-form-item label="业务合作" prop="businessCooperation">
              <el-select
                v-model="formData.businessCooperation"
                class="flex-1"
                placeholder="请输入业务合作"
              >
                <el-option label="商标基础" value="1" />
                <el-option label="商标项目" value="2" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="业务人员编号" prop="businessPersonnelId">
                <el-input
                  v-model="formData.businessPersonnelId"
                  placeholder="请输入业务人员编号"
                />
              </el-form-item> -->
            <el-form-item label="业务人员" prop="businessPersonnel">
              <!-- <el-input
                  v-model="formData.businessPersonnel"
                  style="width: 300px"
                  placeholder="请输入业务人员"
                /> -->
              <el-select
                v-model="formData.businessPersonnel"
                class="flex-1"
                placeholder="请输入业务人员"
              >
                <el-option label="流程01" value="1" />
                <el-option label="科技服务测试" value="2" />
              </el-select>
              <el-button type="primary"> 变更历史 </el-button>
            </el-form-item>
            <!-- <el-form-item label="业务助理编号" prop="businessAssistantId">
                <el-input
                  v-model="formData.businessAssistantId"
                  placeholder="请输入业务助理编号"
                />
              </el-form-item> -->
            <el-form-item label="业务助理" prop="businessAssistant">
              <el-select
                v-model="formData.businessAssistant"
                class="flex-1"
                placeholder="请输入业务助理"
              >
                <el-option label="代理人02" value="1" />
                <el-option label="代理人03" value="2" />
                <el-option label="张一" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="流程人员编号" prop="processPersonnelId">
                <el-input
                  v-model="formData.processPersonnelId"
                  placeholder="请输入流程人员编号"
                />
              </el-form-item> -->
            <el-form-item label="流程人员" prop="processPersonnel">
              <el-select
                v-model="formData.processPersonnel"
                class="flex-1"
                placeholder="请输入流程人员"
              >
                <el-option label="代理人02" value="1" />
                <el-option label="代理人03" value="2" />
                <el-option label="张一" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="所属分部编号" prop="subdivisionId">
                <el-input
                  v-model="formData.subdivisionId"
                  placeholder="请输入所属分部编号"
                />
              </el-form-item> -->
            <el-form-item label="所属分部" prop="subdivision">
              <el-select v-model="formData.subdivision" class="flex-1" placeholder="请输入所属分部">
                <el-option label="深圳" value="1" />
                <el-option label="西安" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="客户签约日期" prop="contractedCustomerTime">
              <el-date-picker
                class="flex-1 !flex"
                v-model="formData.contractedCustomerTime"
                type="datetime"
                clearable
                value-format="YYYY-MM-DD hh:mm:ss"
                placeholder="请输入客户签约日期"
              />
            </el-form-item>
            <el-form-item label="成交状态" prop="makebargainStatus">
              <el-select
                v-model="formData.makebargainStatus"
                class="flex-1"
                placeholder="请输入成交状态"
              >
                <el-option label="是" value="1" />
                <el-option label="否" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="创建日期" prop="basicsCreateTime">
              <el-date-picker
                class="flex-1 !flex"
                v-model="formData.basicsCreateTime"
                type="datetime"
                clearable
                value-format="YYYY-MM-DD hh:mm:ss"
                placeholder="请输入创建日期"
              />
            </el-form-item>
            <el-form-item label="创建人" prop="basicsCreateName">
              <el-input v-model="formData.basicsCreateName" placeholder="请输入创建人" />
            </el-form-item>
            <!-- <el-form-item label="协作人编号" prop="associatesId">
                <el-input
                  v-model="formData.associatesId"
                  placeholder="请输入协作人编号"
                />
              </el-form-item> -->
            <el-form-item label="协作人" prop="associates">
              <el-select v-model="formData.associates" class="flex-1" placeholder="请输入协作人">
                <el-option label="代理人02" value="1" />
                <el-option label="代理人03" value="2" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="案源公司编号" prop="caseSourceCompanyId">
                <el-input
                  v-model="formData.caseSourceCompanyId"
                  placeholder="请输入案源公司编号"
                />
              </el-form-item> -->
            <el-form-item label="案源公司" prop="caseSourceCompany">
              <el-select
                v-model="formData.caseSourceCompany"
                class="flex-1"
                placeholder="请输入案源公司"
              >
                <el-option label="案源公司01" value="1" />
                <el-option label="案源公司02" value="2" />
              </el-select>
            </el-form-item>
            <!-- 1<el-form-item label="黑名单" prop="heimingdan">
                <el-input
                  v-model="formData.heimingdan"
                  placeholder="请输入黑名单"
                />
              </el-form-item>
              <el-form-item label="优先代理人名单" prop="youxiandailiren">
                <el-input
                  v-model="formData.youxiandailiren"
                  placeholder="请输入案源公司"
                />
              </el-form-item>
              <el-form-item label="主力代理人" prop="zhulidailiren">
                <el-input
                  v-model="formData.zhulidailiren"
                  style="width: 330px"
                  placeholder="请输入主力代理人"
                />
                <el-button type="primary"> 详情 </el-button>
              </el-form-item> 1-->
            <!-- <el-form-item label="代理等级编号" prop="agencyGradeId">
                <el-input
                  v-model="formData.agencyGradeId"
                  placeholder="请输入代理等级编号"
                />
              </el-form-item> -->
            <el-form-item label="代理等级" prop="agencyGrade">
              <el-select class="flex-1" v-model="formData.agencyGrade" placeholder="请选择代理等级">
                <el-option label="1级" value="1" />
                <el-option label="2级" value="2" />
                <el-option label="3级" value="3" />
                <el-option label="4级" value="4" />
                <el-option label="5级" value="5" />
                <el-option label="6级" value="6" />
                <el-option label="7级" value="7" />
                <el-option label="8级" value="8" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="客户规模编号" prop="customerSizeId">
                <el-input
                  v-model="formData.customerSizeId"
                  placeholder="请输入客户规模编号"
                />
              </el-form-item> -->
            <el-form-item label="客户规模" prop="customerSize">
              <el-select
                class="flex-1"
                v-model="formData.customerSize"
                placeholder="请输入客户规模"
              >
                <el-option label="大型客户" value="1" />
                <el-option label="中型客户" value="2" />
                <el-option label="小型客户" value="3" />
                <el-option label="一级-新" value="4" />
                <el-option label="一级-老" value="5" />
                <el-option label="二级-新" value="6" />
                <el-option label="二级-老" value="7" />
                <el-option label="三级-新" value="8" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="非主力代理人编号" prop="nonPrincipalAgentId">
                <el-input
                  v-model="formData.nonPrincipalAgentId"
                  placeholder="请输入非主力代理人编号"
                />
              </el-form-item> -->
            <el-form-item label="非主力代理人" prop="nonPrincipalAgent">
              <el-select
                class="flex-1"
                v-model="formData.nonPrincipalAgent"
                placeholder="请输入非主力代理人"
              >
                <el-option label="代理人02" value="1" />
                <el-option label="代理人03" value="2" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="更新人员编号" prop="uploadsUserId">
                <el-input
                  v-model="formData.uploadsUserId"
                  placeholder="请输入更新人员编号"
                />
              </el-form-item> -->
            <el-form-item label="更新人员" prop="uploadsUserName">
              <el-input v-model="formData.uploadsUserName" placeholder="请输入更新人员" />
            </el-form-item>
            <el-form-item label="修改时间" prop="uploadsTime">
              <el-date-picker
                class="flex-1 !flex"
                v-model="formData.uploadsTime"
                type="datetime"
                clearable
                value-format="YYYY-MM-DD hh:mm:ss"
                placeholder="请输入修改时间"
              />
            </el-form-item>
            <el-form-item label="客户系统ip" prop="clientIp">
              <el-input v-model="formData.clientIp" placeholder="请输入客户系统ip" />
            </el-form-item>
            <el-form-item label="客户系统账号" prop="clientAccount">
              <el-input v-model="formData.clientAccount" placeholder="请输入客户系统账号" />
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="formData.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-collapse-item>
          <el-collapse-item title="联系信息" name="2">
            <el-form-item label="联系方式" prop="contactInformation">
              <el-select
                class="flex-1"
                v-model="formData.contactInformation"
                placeholder="请输入联系方式"
              >
                <el-option label="电话" value="1" />
                <el-option label="微信" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="昵称" prop="nickname">
              <el-input v-model="formData.nickname" placeholder="请输入昵称" />
            </el-form-item>
            <el-form-item label="电话" prop="phone">
              <el-input v-model="formData.phone" style="width: 270px" placeholder="请输入电话" />
              <el-button type="primary"> 同步至联系人 </el-button>
            </el-form-item>
            <el-form-item label="传真" prop="fax">
              <el-input v-model="formData.fax" style="width: 270px" placeholder="请输入传真" />
              <el-button type="primary"> 同步至联系人 </el-button>
            </el-form-item>
            <el-form-item label="邮件" prop="email">
              <el-input v-model="formData.email" style="width: 270px" placeholder="请输入邮件" />
              <el-button type="primary"> 同步至联系人 </el-button>
            </el-form-item>
            <el-form-item label="邮编" prop="postcode">
              <el-input v-model="formData.postcode" placeholder="请输入邮编" />
            </el-form-item>
          </el-collapse-item>
          <el-collapse-item title="客户评估" name="3">
            <!-- <el-form-item label="客户等级编号" prop="clientGradeId">
                <el-input
                  v-model="formData.clientGradeId"
                  placeholder="请输入客户等级编号"
                />
              </el-form-item> -->
            <el-form-item label="客户等级" prop="clientGrade">
              <el-select class="flex-1" v-model="formData.clientGrade" placeholder="请选择客户等级">
                <el-option label="一般客户" value="1" />
                <el-option label="重要客户" value="2" />
                <el-option label="潜在客户" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="信誉等级编号" prop="reputationGradeId">
                <el-input
                  v-model="formData.reputationGradeId"
                  placeholder="请输入信誉等级编号"
                />
              </el-form-item> -->
            <el-form-item label="信誉等级" prop="reputationGrade">
              <el-select
                class="flex-1"
                v-model="formData.reputationGrade"
                placeholder="请选择信誉等级"
              >
                <el-option label="高度信誉" value="1" />
                <el-option label="中度信誉" value="2" />
                <el-option label="低度信誉" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="保密等级编号" prop="confidentialityGradeId">
                <el-input
                  v-model="formData.confidentialityGradeId"
                  placeholder="请输入保密等级编号"
                />
              </el-form-item> -->
            <el-form-item label="保密等级" prop="confidentialityGrade">
              <el-select
                class="flex-1"
                v-model="formData.confidentialityGrade"
                placeholder="请选择保密等级"
              >
                <el-option label="低度" value="1" />
                <el-option label="中度" value="2" />
                <el-option label="高度" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="客户来源编号" prop="customerSourceId">
                <el-input
                  v-model="formData.customerSourceId"
                  placeholder="请输入客户来源编号"
                />
              </el-form-item> -->
            <el-form-item label="客户来源" prop="customerSource">
              <el-select
                class="flex-1"
                v-model="formData.customerSource"
                placeholder="请输入客户来源"
              >
                <el-option label="客户介绍" value="1" />
                <el-option label="老客户" value="2" />
                <el-option label="电话采访" value="3" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="客户镇区编号" prop="customerTownshipId">
                <el-input
                  v-model="formData.customerTownshipId"
                  placeholder="请输入客户镇区编号"
                />
              </el-form-item> -->
            <el-form-item label="客户镇区" prop="customerTownship">
              <el-select
                class="flex-1"
                v-model="formData.customerTownship"
                placeholder="请输入客户镇区"
              >
                <el-option label="请选择" value="1" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="客户园区编号" prop="customerGardenId">
                <el-input
                  v-model="formData.customerGardenId"
                  placeholder="请输入客户园区编号"
                />
              </el-form-item> -->
            <el-form-item label="客户园区" prop="customerGarden">
              <el-select
                class="flex-1"
                v-model="formData.customerGarden"
                placeholder="请输入客户园区"
              >
                <el-option label="请选择" value="1" />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="客户类型编号" prop="customerTypeId">
                <el-input
                  v-model="formData.customerTypeId"
                  placeholder="请输入客户类型编号"
                />
              </el-form-item> -->
            <el-form-item label="客户类型" prop="customerType">
              <el-select
                class="flex-1"
                v-model="formData.customerType"
                placeholder="请选择客户类型"
              >
                <el-option label="计划联系客户" value="1" />
                <el-option label="已联系客户" value="2" />
                <el-option label="现有客户" value="3" />
              </el-select>
            </el-form-item>
          </el-collapse-item>
          <el-collapse-item title="案源信息" name="4">
            <el-form-item label="内部案源人" prop="internalSource">
              <el-input v-model="formData.internalSource" placeholder="请输入内部案源人" />
            </el-form-item>
            <el-form-item label="内部案源人电话" prop="internalSourcePhone">
              <el-input v-model="formData.internalSourcePhone" placeholder="请输入内部案源人电话" />
            </el-form-item>
            <el-form-item label="内部案源人邮箱" prop="internalSourceEmail">
              <el-input v-model="formData.internalSourceEmail" placeholder="请输入内部案源人邮箱" />
            </el-form-item>
            <el-form-item label="外部案源人" prop="externalCaseSource">
              <el-input v-model="formData.externalCaseSource" placeholder="请输入外部案源人" />
            </el-form-item>
            <el-form-item label="外部案源人电话" prop="externalCasePhone">
              <el-input v-model="formData.externalCasePhone" placeholder="请输入外部案源人电话" />
            </el-form-item>
            <el-form-item label="外部案源人邮箱" prop="externalCaseEmail">
              <el-input v-model="formData.externalCaseEmail" placeholder="请输入外部案源人邮箱" />
            </el-form-item>
            <!-- <el-form-item label="案源类型编号" prop="sourceTypeId">
                <el-input
                  v-model="formData.sourceTypeId"
                  placeholder="请输入案源类型编号"
                />
              </el-form-item> -->
            <el-form-item label="案源类型" prop="sourceType">
              <el-select v-model="formData.sourceType" class="flex-1" placeholder="请选择案源类型">
                <el-option label="市区工会" value="1" />
                <el-option label="大学研讨会" value="2" />
              </el-select>
            </el-form-item>
          </el-collapse-item>
          <el-collapse-item title="费用信息" name="5">
            <el-form-item label="账单地址" prop="billingAddress">
              <el-input v-model="formData.billingAddress" placeholder="请输入账单地址" />
            </el-form-item>
            <el-form-item label="缴费抬头" prop="paymentTitle">
              <el-input v-model="formData.paymentTitle" placeholder="请输入缴费抬头" />
            </el-form-item>
            <el-form-item label="纳税人识别号(信用代码)" prop="identificationNumberTaxpayer">
              <el-input
                v-model="formData.identificationNumberTaxpayer"
                placeholder="请输入纳税人识别号(信用代码)"
              />
            </el-form-item>
            <el-form-item label="发票抬头" prop="invoiceTitle">
              <el-input v-model="formData.invoiceTitle" placeholder="请输入发票抬头" />
            </el-form-item>
            <el-form-item label="开户银行" prop="depositBank">
              <el-input v-model="formData.depositBank" placeholder="请输入开户银行" />
            </el-form-item>
            <el-form-item label="银行账号" prop="bankAccount">
              <el-input v-model="formData.bankAccount" placeholder="请输入银行账号" />
            </el-form-item>
            <el-form-item label="年度销售收入" prop="annualSalesRevenue">
              <el-input v-model="formData.annualSalesRevenue" placeholder="请输入年度销售收入" />
            </el-form-item>
            <el-form-item label="一般纳税人" prop="generalTaxpayer">
              <el-select
                class="flex-1"
                v-model="formData.generalTaxpayer"
                placeholder="请输入一般纳税人"
              >
                <el-option label="是" value="1" />
                <el-option label="否" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="代理费折扣率" prop="agencyDiscountRate">
              <el-input v-model="formData.agencyDiscountRate" placeholder="请输入代理费折扣率" />
            </el-form-item>
            <el-form-item label="开户名称" prop="accountName">
              <el-input v-model="formData.accountName" placeholder="请输入开户名称" />
            </el-form-item>
            <el-form-item label="总资产" prop="totalAssets">
              <el-input v-model="formData.totalAssets" placeholder="请输入总资产" />
            </el-form-item>
            <el-form-item label="电话信息" prop="phoneInfo">
              <el-input v-model="formData.phoneInfo" placeholder="请输入电话信息" />
            </el-form-item>
          </el-collapse-item>
          <el-collapse-item title="地址信息" name="6">
            <el-form-item label="国家(地区)" prop="nation">
              <el-select class="flex-1" v-model="formData.nation" placeholder="请输入国家(地区)">
                <el-option label="中国" value="1" />
                <el-option label="其他" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="省份" prop="province">
              <el-select class="flex-1" v-model="formData.province" placeholder="请输入省份">
                <el-option label="北京(Beijing)" value="1" />
                <el-option label="上海(Shanghai)" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="城市(中文)" prop="cityChinese">
              <el-select
                class="flex-1"
                v-model="formData.cityChinese"
                placeholder="请输入城市(中文)"
              >
                <el-option label="北京(Beijing)" value="1" />
                <el-option label="上海(Shanghai)" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="行政区划" prop="administrativeDivision">
              <el-select
                class="flex-1"
                v-model="formData.administrativeDivision"
                placeholder="请输入行政区划"
              >
                <el-option label="111" value="1" />
                <el-option label="222" value="2" />
              </el-select>
            </el-form-item>
            <el-form-item label="经营地址" prop="businessAddress">
              <el-input v-model="formData.businessAddress" placeholder="请输入经营地址" />
            </el-form-item>
            <el-form-item label="经营电话" prop="businessPhone">
              <el-input v-model="formData.businessPhone" placeholder="请输入经营电话" />
            </el-form-item>
            <el-form-item label="地址" prop="addressChinese">
              <el-input
                v-model="formData.addressChinese"
                style="width: 270px"
                placeholder="请输入地址"
              />
              <el-button type="primary"> 同步至联系人 </el-button>
            </el-form-item>
            <el-form-item label="英文地址" prop="addressEnglish">
              <el-input
                v-model="formData.addressEnglish"
                style="width: 270px"
                placeholder="请输入英文地址"
              />
              <el-button type="primary"> 同步至联系人 </el-button>
            </el-form-item>
            <el-form-item label="其他地址" prop="additionalAddress">
              <el-input v-model="formData.additionalAddress" placeholder="请输入其他地址" />
            </el-form-item>
          </el-collapse-item>
        </el-collapse>
      </el-form>
    </el-card>
    <el-card class="mt-4 !border-none" shadow="never" @tab-click="handleClick">
      <el-tabs v-model="activeName">
        <el-tab-pane label="联系人" name="linkman">
          联系人
          <!-- <edit-popup v-if="showEdit" ref="editRef" /> -->
        </el-tab-pane>
        <el-tab-pane label="申请人" name="proposer">申请人</el-tab-pane>
        <el-tab-pane label="发明人" name="inventor"></el-tab-pane>
        <el-tab-pane label="客户期限规则人" name="customertermrule"> </el-tab-pane>
        <el-tab-pane label="客户要求" name="customerrequire"> 客户要求</el-tab-pane>
        <el-tab-pane label="联系记录" name="second">联系记录 </el-tab-pane>
        <el-tab-pane label="客户文件" name="customerfile;">客户文件</el-tab-pane>
        <el-tab-pane label="客户档案" name="clientcase;">客户档案</el-tab-pane>
        <el-tab-pane label="发文规则配置" name="dispatchruleconfiguration"
          >发文规则配置</el-tab-pane
        >
        <el-tab-pane label="文件重命名规则" name="lafilerenamingrule;">文件重命名规则</el-tab-pane>
        <el-tab-pane label="平台用户" name="platformuser">平台用户</el-tab-pane>
        <el-tab-pane label="合同" name="contract">合同</el-tab-pane>
        <el-tab-pane label="发文记录" name="documentrecord">发文记录</el-tab-pane>
        <el-tab-pane label="客户关联" name="customerrelevance">客户关联</el-tab-pane>
        <el-tab-pane label="竞业关联" name="competitionrelevance">竞业关联</el-tab-pane>
        <el-tab-pane label="规则邮件配置" name="emailruleconfiguration">规则邮件配置</el-tab-pane>
      </el-tabs>
    </el-card>
    <footer-btns>
      <el-button type="primary" @click="handleSubmit">保存</el-button>
    </footer-btns>
  </div>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import { customerColEdit, customerColAdd, customerColDetail } from '@/api/customer/customerColList'
import feedback from '@/utils/feedback'
import Popup from '@/components/popup/index.vue'
defineProps({
  dictData: {
    type: Object as PropType<Record<string, any[]>>,
    default: () => ({})
  }
})
const emit = defineEmits(['success', 'close'])
const route = useRoute()
const router = useRouter()
const formRef = shallowRef<FormInstance>()
// const mode = ref("add");
// const popupTitle = computed(() => {
//   return mode.value == "edit" ? "编辑客户列" : "新增客户列";
// });
const activeNames = ['1', '2', '3', '4', '5', '6']
const activeName = 'linkman'

const formData = reactive({
  id: '',
  customerId: '',
  caseType: [],
  customerCode: '',
  customerNameChinese: '',
  customerNameEnglish: '',
  customerWebsite: '',
  companyOfficials: '',
  industryInvolvedId: '',
  industryInvolved: '',
  businessCooperationId: '',
  businessCooperation: '',
  businessPersonnelId: '',
  businessPersonnel: '',
  businessAssistantId: '',
  businessAssistant: '',
  processPersonnelId: '',
  processPersonnel: '',
  subdivisionId: '',
  subdivision: '',
  contractedCustomerTime: '',
  makebargainStatus: '',
  basicsCreateTime: '',
  basicsCreateName: '',
  associatesId: '',
  associates: '',
  caseSourceCompanyId: '',
  caseSourceCompany: '',
  agencyGradeId: '',
  agencyGrade: '',
  customerSizeId: '',
  customerSize: '',
  nonPrincipalAgentId: '',
  nonPrincipalAgent: '',
  uploadsUserId: '',
  uploadsUserName: '',
  uploadsTime: '',
  clientIp: '',
  clientAccount: '',
  remark: '',
  contactInformation: '',
  nickname: '',
  phone: '',
  fax: '',
  email: '',
  postcode: '',
  clientGradeId: '',
  clientGrade: '',
  reputationGradeId: '',
  reputationGrade: '',
  confidentialityGradeId: '',
  confidentialityGrade: '',
  customerSourceId: '',
  customerSource: '',
  customerTownshipId: '',
  customerTownship: '',
  customerGardenId: '',
  customerGarden: '',
  customerTypeId: '',
  customerType: '',
  internalSource: '',
  internalSourcePhone: '',
  internalSourceEmail: '',
  externalCaseSource: '',
  externalCasePhone: '',
  externalCaseEmail: '',
  sourceTypeId: '',
  sourceType: '',
  billingAddress: '',
  paymentTitle: '',
  identificationNumberTaxpayer: '',
  invoiceTitle: '',
  depositBank: '',
  bankAccount: '',
  annualSalesRevenue: '',
  generalTaxpayer: '',
  agencyDiscountRate: '',
  accountName: '',
  totalAssets: '',
  phoneInfo: '',
  nation: '',
  province: '',
  cityChinese: '',
  administrativeDivision: '',
  businessAddress: '',
  businessPhone: '',
  addressChinese: '',
  addressEnglish: '',
  additionalAddress: '',
  patentQuantity: '',
  numberOfTrademarks: '',
  copyrightNumber: '',
  evaluationBasis: '',
  followUpTime: '',
  unfollowedId: '',
  unfollowed: '',
  updateUserId: ''
})

const formRules = {
  caseType: [
    {
      required: true,
      message: '请选择案件类型',
      trigger: ['blur']
    }
  ],
  customerNameChinese: [
    {
      required: true,
      message: '请输入客户名称(中)',
      trigger: ['blur']
    }
  ],
  businessPersonnel: [
    {
      required: true,
      message: '请输入业务人员',
      trigger: ['blur']
    }
  ]
}

// const handleSubmit = async () => {
//   await formRef.value?.validate();
//   const data: any = { ...formData };
//   mode.value == "edit"
//     ? await customerlistEdit(data)
//     : await customerlistAdd(data);
//   popupRef.value?.close();
//   feedback.msgSuccess("操作成功");
//   emit("success");
// };
const handleSubmit = async () => {
  await formRef.value?.validate()
  const data: any = { ...formData }
  if (route.query.id) {
    await customerColEdit(data)
  } else {
    await customerColAdd(data)
  }
  feedback.msgSuccess('操作成功')
  emit('success')
  removeTab()
  router.back()
}
const open = (type = 'add') => {
  mode.value = type
  popupRef.value?.open()
}

const setFormData = async (data: Record<string, any>) => {
  for (const key in formData) {
    if (data[key] != null && data[key] != undefined) {
      //@ts-ignore
      formData[key] = data[key]
    }
  }
}

const getDetail = async (row: Record<string, any>) => {
  const data = await customerColDetail({
    id: row.id
  })
  setFormData(data)
}

const handleClose = () => {
  emit('close')
}

// const cityOptions = ["上海", "北京", "广州", "深圳"];

// const data = reactive({
//   checkAll: false,
//   checkedCities: ["上海", "北京"],
//   cities: cityOptions,
//   isIndeterminate: true,
// });
const handleCheckAllChange = async (val: any) => {
  if (val) {
    formData.caseType = ['全选', '专利', '商标', '版权', '科技服务', '法律案件', '调查案']
    val = false
  } else {
    formData.caseType = []
  }
}

// const handleCheckedCitiesChange = async (value: any) => {
//   let checkedCount = value.length;
//   data.checkAll = checkedCount === data.cities.length;
//   data.isIndeterminate = checkedCount > 0 && checkedCount < data.cities.length;
// };

defineExpose({
  open,
  setFormData,
  getDetail
})
</script>
<style scoped>
.formEdit .el-form-item {
  width: 590px;
}
::v-deep .el-collapse-item__header {
  padding-left: 54px;
  background-color: var(--el-bg-color-collapse);
  font-size: 16px;
  font-weight: 600;
  color: var(--el-text-color-collapse);
}
::v-deep .el-collapse-item__wrap {
  padding-top: 20px;
}
</style>
